Maybe Data is Lost in result of type conversion (MDL)

Description:

This message is reported when significant bits may be lost because of a conversion from a large integer type to a smaller integer type. Such conversions are always explicitly specified by the programmer, and MDL tries to reduce the number of reported messages caused by data truncation.

Incorrect:

The example below illustrates suspicious cases detected by MDL.

procedure foo(x:integer; y:longint);
var
s:smallint;
c:word;
b:byte;
begin
  c := x and $FFFF0;
  b := x and $FF0;
  b := x shr 23;
  s := x and $FFFF0;
end;

Correct:

For the following example, no warning messages are produced.

procedure foo(x:integer; y:longint);
var
s:smallint;
c:word;
b:byte;
begin
  c := x and $FFFF;
  b := x and $FF;
  b := x shr 24;
  s := x and $FFFF;
end;